package run.siyuan.rabbitmq.retry.message.config;

import org.springframework.amqp.core.Queue;
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;
import run.siyuan.common.constant.rabbitmq.Constants;

@Component
public class ServiceRabbitmqConfig {

    /**
     * 业务队列
     * @return
     */
    @Bean
    public Queue serviceQueue() {
        return new Queue(Constants.Queue.RABBITMQ_SERVICE_QUEUE);
    }

    @Bean
    public RabbitTemplate jsonRabbitTemplate(ConnectionFactory connectionFactory) {
        RabbitTemplate rabbitTemplate = new RabbitTemplate(connectionFactory);
        rabbitTemplate.setMessageConverter(new Jackson2JsonMessageConverter());
        return rabbitTemplate;
    }

}
